package cn.xiuxius.embedded.dependencyscan;

import lombok.Getter;

import java.util.Locale;

@Getter
public enum FileType {
    C(1, ".c"),
    A51(2, ".a51"),
    LIB(4, ".lib"),
    H(5,".h"),
    TXT(5,".txt"),
    CPP(8,".cpp"),
    UNKNOWN(0, ".unknown");

    private final int num;

    private final String suffix;

    FileType(int num, String suffix) {
        this.num = num;
        this.suffix = suffix;
    }

    public static FileType fromFileName(String filename) {
        for (FileType type : FileType.values()) {
            if (filename.toLowerCase(Locale.ROOT).endsWith(type.getSuffix())) {
                return type;
            }
        }
        return UNKNOWN;
    }

}
